/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package gui;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import javax.swing.JTable;
import javax.swing.table.TableModel;

  
/**
 *
 * @author ANNM
 */
public class XuatExcel {
    public void XuatFile(JTable table, File file) throws IOException {  
            TableModel model = table.getModel(); 
            FileWriter out = new FileWriter(file); 
            for(int i=0; i < model.getColumnCount();i++) { 
             out.write(model.getColumnName(i)+"\t"); 
           } 
           out.write("\n"); 
           for(int i=0; i < model.getRowCount();i++){ 

            for(int j=0;j < model.getColumnCount();j++){ 
             if(j==0) { 
              out.write(model.getValueAt(i,j).toString() + "\t"); 
             } else { 
          //    out.write("\""+model.getValueAt(i, j).toString()+"\t"+"\""); 
                  out.write(model.getValueAt(i, j).toString()+"\t"); 
             } 
            } 
            out.write("\n"); 
           } 
           out.close(); 
    } 
  
} 
